package com.ctshk.rpc.tour.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.tour.entity.SeriesTripScheduleInfoChangeRule;
import com.ctshk.rpc.tour.req.schedule.TripScheduleChangeRuleDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 团期旅客资料收费规则 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-02
 */
public interface SeriesTripScheduleInfoChangeRuleMapper extends BaseMapper<SeriesTripScheduleInfoChangeRule> {

    /**
     * 根据团期ID获取规格列表
     * @param id
     * @return
     */
    @Select("SELECT id,main_data_id,`name`,amount\n" +
            "FROM t_series_trip_schedule_info_change_rule\n" +
            "WHERE schedule_id = #{schedule_id} AND is_deleted = 0")
    List<TripScheduleChangeRuleDTO> queryBySchedule(@Param("schedule_id") Long id);

    /**
     * 清空更改资料规则
     * @param tripId
     * @param ruleId
     * @param userId
     */
    @Update("UPDATE t_series_trip_info_change_rule\n" +
            "SET is_deleted = 1,modified_id = #{modified_id}\n" +
            "WHERE trip_id = #{trip_id} AND group_rule_id = #{group_rule_id} AND is_deleted = 0")
    void cleanByTrip(@Param("trip_id") Long tripId,@Param("group_rule_id") Long ruleId,@Param("modified_id") Long userId);
}
